#include "innermap.h"
#include "ui_innermap.h"
#include <QMouseEvent>
#include <QPainter>
const int INF = 0x3f3f3f3f;
const int NN = 10;

innermap::innermap(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::innermap)
{
    ui->setupUi(this);
    this->getx["oneap"]=ui->oneap->pos().rx();
    this->gety["oneap"]=ui->oneap->pos().ry();
    this->getwidth["oneap"]=ui->oneap->width();
    this->getheight["oneap"]=ui->oneap->height();

    this->getx["twoap"]=ui->twoap->pos().rx();
    this->gety["twoap"]=ui->twoap->pos().ry();
    this->getwidth["twoap"]=ui->twoap->width();
    this->getheight["twoap"]=ui->twoap->height();

    this->getx["threeap"]=ui->threeap->pos().rx();
    this->gety["threeap"]=ui->threeap->pos().ry();
    this->getwidth["threeap"]=ui->threeap->width();
    this->getheight["threeap"]=ui->threeap->height();

    this->getx["oneed"]=ui->oneed->pos().rx();
    this->gety["oneed"]=ui->oneed->pos().ry();
    this->getwidth["oneed"]=ui->oneed->width();
    this->getheight["oneed"]=ui->oneed->height();

    this->getx["twoed"]=ui->twoed->pos().rx();
    this->gety["twoed"]=ui->twoed->pos().ry();
    this->getwidth["twoed"]=ui->twoed->width();
    this->getheight["twoed"]=ui->twoed->height();

    this->getx["threeed"]=ui->threeed->pos().rx();
    this->gety["threeed"]=ui->threeed->pos().ry();
    this->getwidth["threeed"]=ui->threeed->width();
    this->getheight["threeed"]=ui->threeed->height();

    this->getx["lab"]=ui->lab->pos().rx();
    this->gety["lab"]=ui->lab->pos().ry();
    this->getwidth["lab"]=ui->lab->width();
    this->getheight["lab"]=ui->lab->height();

    this->getx["cafe"]=ui->cafe->pos().rx();
    this->gety["cafe"]=ui->cafe->pos().ry();
    this->getwidth["cafe"]=ui->cafe->width();
    this->getheight["cafe"]=ui->cafe->height();

    this->getx["play"]=ui->play->pos().rx();
    this->gety["play"]=ui->play->pos().ry();
    this->getwidth["play"]=ui->play->width();
    this->getheight["play"]=ui->play->height();

    this->getx["spt"]=ui->spt->pos().rx();
    this->gety["spt"]=ui->spt->pos().ry();
    this->getwidth["spt"]=ui->spt->width();
    this->getheight["spt"]=ui->spt->height();




    this->setWindowTitle("多功能导航系统V1.0");
    this->setWindowIcon(QIcon("://res/nav.png"));
    this->setFixedSize(1120,693);

    // 地图窗口样式
    ui->site->setStyleSheet(QString::fromUtf8("#site{border:3px solid black}"));


    //添加起点
    /****注意！这里排放顺序要和在邻接矩阵的顺序一致！*****/
    ui->startBox->addItem("1公寓");
    ui->startBox->addItem("2公寓");
    ui->startBox->addItem("3公寓");
    ui->startBox->addItem("1教");
    ui->startBox->addItem("2教");
    ui->startBox->addItem("3教");
    ui->startBox->addItem("实验楼");
    ui->startBox->addItem("东餐");
    ui->startBox->addItem("北操场");
    ui->startBox->addItem("超市");
    //添加终点
    ui->endBox->addItem("1公寓");
    ui->endBox->addItem("2公寓");
    ui->endBox->addItem("3公寓");
    ui->endBox->addItem("1教");
    ui->endBox->addItem("2教");
    ui->endBox->addItem("3教");
    ui->endBox->addItem("实验楼");
    ui->endBox->addItem("东餐");
    ui->endBox->addItem("北操场");
    ui->endBox->addItem("超市");


    //地图定位信息的实现（单击事件）
    connect(ui->oneap,&QPushButton::clicked,[=](){
        ui->nodeinfo->setText("");//清空原有信息
        QString inname = "1公寓";
        int inid = icc.getId["oneap"];
        ui->nodeinfo->insertPlainText("场景名称： "+inname+"\n"
                              +"位置：("+QString::number(icc.in[inid].x,10)
                              +","+QString::number(icc.in[inid].y,10)+")\n"
                              +"相邻区域： \n");
        int t=0;
        for(int i=0;i<icc.inum;i++){
            if(icc.dir[inid][i]!=INF){
                ui->nodeinfo->insertPlainText(inname+"距离"+
                                      QString::fromStdString(icc.in[i].name)
                                      +QString::number(icc.dir[inid][i],10)+"米\n");
                t++;
            }
        }
        if(t==0){
            ui->nodeinfo->insertPlainText("该城市没有相邻城市！");
        }

    });

    connect(ui->twoap,&QPushButton::clicked,[=](){
        ui->nodeinfo->setText("");//清空原有信息
        QString inname = "2公寓";
        int inid = icc.getId["twoap"];
        ui->nodeinfo->insertPlainText("场景名称： "+inname+"\n"
                              +"位置：("+QString::number(icc.in[inid].x,10)
                              +","+QString::number(icc.in[inid].y,10)+")\n"
                              +"相邻区域： \n");
        int t=0;
        for(int i=0;i<icc.inum;i++){
            if(icc.dir[inid][i]!=INF){
                ui->nodeinfo->insertPlainText(inname+"距离"+
                                      QString::fromStdString(icc.in[i].name)
                                      +QString::number(icc.dir[inid][i],10)+"米\n");
                t++;
            }
        }
        if(t==0){
            ui->nodeinfo->insertPlainText("该城市没有相邻城市！");
        }

    });

    connect(ui->threeap,&QPushButton::clicked,[=](){
        ui->nodeinfo->setText("");//清空原有信息
        QString inname = "3公寓";
        int inid = icc.getId["threeap"];
        ui->nodeinfo->insertPlainText("场景名称： "+inname+"\n"
                              +"位置：("+QString::number(icc.in[inid].x,10)
                              +","+QString::number(icc.in[inid].y,10)+")\n"
                              +"相邻区域： \n");
        int t=0;
        for(int i=0;i<icc.inum;i++){
            if(icc.dir[inid][i]!=INF){
                ui->nodeinfo->insertPlainText(inname+"距离"+
                                      QString::fromStdString(icc.in[i].name)
                                      +QString::number(icc.dir[inid][i],10)+"米\n");
                t++;
            }
        }
        if(t==0){
            ui->nodeinfo->insertPlainText("该城市没有相邻城市！");
        }

    });

    connect(ui->oneed,&QPushButton::clicked,[=](){
        ui->nodeinfo->setText("");//清空原有信息
        QString inname = "1教";
        int inid = icc.getId["oneed"];
        ui->nodeinfo->insertPlainText("场景名称： "+inname+"\n"
                              +"位置：("+QString::number(icc.in[inid].x,10)
                              +","+QString::number(icc.in[inid].y,10)+")\n"
                              +"相邻区域： \n");
        int t=0;
        for(int i=0;i<icc.inum;i++){
            if(icc.dir[inid][i]!=INF){
                ui->nodeinfo->insertPlainText(inname+"距离"+
                                      QString::fromStdString(icc.in[i].name)
                                      +QString::number(icc.dir[inid][i],10)+"米\n");
                t++;
            }
        }
        if(t==0){
            ui->nodeinfo->insertPlainText("该城市没有相邻城市！");
        }

    });

    connect(ui->twoed,&QPushButton::clicked,[=](){
        ui->nodeinfo->setText("");//清空原有信息
        QString inname = "2教";
        int inid = icc.getId["twoed"];
        ui->nodeinfo->insertPlainText("场景名称： "+inname+"\n"
                              +"位置：("+QString::number(icc.in[inid].x,10)
                              +","+QString::number(icc.in[inid].y,10)+")\n"
                              +"相邻区域： \n");
        int t=0;
        for(int i=0;i<icc.inum;i++){
            if(icc.dir[inid][i]!=INF){
                ui->nodeinfo->insertPlainText(inname+"距离"+
                                      QString::fromStdString(icc.in[i].name)
                                      +QString::number(icc.dir[inid][i],10)+"米\n");
                t++;
            }
        }
        if(t==0){
            ui->nodeinfo->insertPlainText("该城市没有相邻城市！");
        }

    });

    connect(ui->threeed,&QPushButton::clicked,[=](){
        ui->nodeinfo->setText("");//清空原有信息
        QString inname = "3教";
        int inid = icc.getId["threeed"];
        ui->nodeinfo->insertPlainText("场景名称： "+inname+"\n"
                              +"位置：("+QString::number(icc.in[inid].x,10)
                              +","+QString::number(icc.in[inid].y,10)+")\n"
                              +"相邻区域： \n");
        int t=0;
        for(int i=0;i<icc.inum;i++){
            if(icc.dir[inid][i]!=INF){
                ui->nodeinfo->insertPlainText(inname+"距离"+
                                      QString::fromStdString(icc.in[i].name)
                                      +QString::number(icc.dir[inid][i],10)+"米\n");
                t++;
            }
        }
        if(t==0){
            ui->nodeinfo->insertPlainText("该城市没有相邻城市！");
        }

    });

    connect(ui->lab,&QPushButton::clicked,[=](){
        ui->nodeinfo->setText("");//清空原有信息
        QString inname = "实验楼";
        int inid = icc.getId["lab"];
        ui->nodeinfo->insertPlainText("场景名称： "+inname+"\n"
                              +"位置：("+QString::number(icc.in[inid].x,10)
                              +","+QString::number(icc.in[inid].y,10)+")\n"
                              +"相邻区域： \n");
        int t=0;
        for(int i=0;i<icc.inum;i++){
            if(icc.dir[inid][i]!=INF){
                ui->nodeinfo->insertPlainText(inname+"距离"+
                                      QString::fromStdString(icc.in[i].name)
                                      +QString::number(icc.dir[inid][i],10)+"米\n");
                t++;
            }
        }
        if(t==0){
            ui->nodeinfo->insertPlainText("该城市没有相邻城市！");
        }

    });

    connect(ui->cafe,&QPushButton::clicked,[=](){
        ui->nodeinfo->setText("");//清空原有信息
        QString inname = "东餐";
        int inid = icc.getId["cafe"];
        ui->nodeinfo->insertPlainText("场景名称： "+inname+"\n"
                              +"位置：("+QString::number(icc.in[inid].x,10)
                              +","+QString::number(icc.in[inid].y,10)+")\n"
                              +"相邻区域： \n");
        int t=0;
        for(int i=0;i<icc.inum;i++){
            if(icc.dir[inid][i]!=INF){
                ui->nodeinfo->insertPlainText(inname+"距离"+
                                      QString::fromStdString(icc.in[i].name)
                                      +QString::number(icc.dir[inid][i],10)+"米\n");
                t++;
            }
        }
        if(t==0){
            ui->nodeinfo->insertPlainText("该城市没有相邻城市！");
        }

    });

    connect(ui->play,&QPushButton::clicked,[=](){
        ui->nodeinfo->setText("");//清空原有信息
        QString inname = "北操场";
        int inid = icc.getId["play"];
        ui->nodeinfo->insertPlainText("场景名称： "+inname+"\n"
                              +"位置：("+QString::number(icc.in[inid].x,10)
                              +","+QString::number(icc.in[inid].y,10)+")\n"
                              +"相邻区域： \n");
        int t=0;
        for(int i=0;i<icc.inum;i++){
            if(icc.dir[inid][i]!=INF){
                ui->nodeinfo->insertPlainText(inname+"距离"+
                                      QString::fromStdString(icc.in[i].name)
                                      +QString::number(icc.dir[inid][i],10)+"米\n");
                t++;
            }
        }
        if(t==0){
            ui->nodeinfo->insertPlainText("该城市没有相邻城市！");
        }

    });

    connect(ui->spt,&QPushButton::clicked,[=](){
        ui->nodeinfo->setText("");//清空原有信息
        QString inname = "超市";
        int inid = icc.getId["spt"];
        ui->nodeinfo->insertPlainText("场景名称： "+inname+"\n"
                              +"位置：("+QString::number(icc.in[inid].x,10)
                              +","+QString::number(icc.in[inid].y,10)+")\n"
                              +"相邻区域： \n");
        int t=0;
        for(int i=0;i<icc.inum;i++){
            if(icc.dir[inid][i]!=INF){
                ui->nodeinfo->insertPlainText(inname+"距离"+
                                      QString::fromStdString(icc.in[i].name)
                                      +QString::number(icc.dir[inid][i],10)+"米\n");
                t++;
            }
        }
        if(t==0){
            ui->nodeinfo->insertPlainText("该城市没有相邻城市！");
        }

    });

     /*-------------------------------------------------导航算法----------------------------------------------------------------------------*/
    connect(ui->beginBtn,&QPushButton::clicked,[=](){
        ui->navinfo->setText("");
        //起点终点编号id
        int startid = ui->startBox->currentIndex();
        int endid = ui->endBox->currentIndex();
        ui->navinfo->insertPlainText("从"+QString::fromStdString(icc.in[startid].name)+"出发，到"+QString::fromStdString(icc.in[endid].name)+"\n\n");
        //出行方式的获取
        if(ui->train->isChecked()){
            ui->navinfo->insertPlainText("距离较短，请选择步行或者骑行!\n\n");
        }
        else if(ui->car->isChecked()){
            ui->navinfo->insertPlainText("距离较短，请选择步行或者骑行!\n\n");
        }
        else if(ui->walk->isChecked()){
            ui->navinfo->insertPlainText("选择骑行\n");
        }
        else if(ui->bike->isChecked()){
            ui->navinfo->insertPlainText("选择步行\n");
        }

        //出行策略的获取
        if(ui->timefirst->isChecked()){
            ui->navinfo->insertPlainText("时间优先\n\n");
        }
        if(ui->disfirst->isChecked()){
            ui->navinfo->insertPlainText("距离优先\n\n");
        }


        if(ui->bike->isChecked()){
            //骑行和步行都不需要计算中转，两点间的道路上没有第三个场所，所以最短距离就是两点间直达距离，
            ui->navinfo->insertPlainText("提倡选择绿色方式，已为您推荐两点最短距离！\n");
            ui->navinfo->insertPlainText("全程"+QString::number(icc.dir[startid][endid],10)+"米\n");
            ui->navinfo->insertPlainText("大约需要"+QString::number(icc.itt[startid][endid])+"分钟\n");
            cx[0]=getx[icc.in[startid].ename]+getwidth[icc.in[startid].ename];
            cy[0]=gety[icc.in[startid].ename]+getheight[icc.in[startid].ename];
            cx[1]=getx[icc.in[endid].ename]+getwidth[icc.in[endid].ename];
            cy[1]=gety[icc.in[endid].ename]+getheight[icc.in[endid].ename];

        }

        if(ui->walk->isChecked()){
            //骑行和步行都不需要计算中转，两点间的道路上没有第三个场所，所以最短距离就是两点间直达距离，
            ui->navinfo->insertPlainText("提倡选择绿色方式，已为您推荐两点最短距离！\n");
            ui->navinfo->insertPlainText("全程"+QString::number(icc.dir[startid][endid],10)+"米\n");
            ui->navinfo->insertPlainText("大约需要"+QString::number(icc.itt[startid][endid])+"分钟\n");
            cx[0]=getx[icc.in[startid].ename]+getwidth[icc.in[startid].ename];
            cy[0]=gety[icc.in[startid].ename]+getheight[icc.in[startid].ename];
            cx[1]=getx[icc.in[endid].ename]+getwidth[icc.in[endid].ename];
            cy[1]=gety[icc.in[endid].ename]+getheight[icc.in[endid].ename];
        }
        this->repaint();

    });
}

innermap::~innermap()
{
    delete ui;
}

void innermap::paintEvent(QPaintEvent *ev)
{
    QPainter painter(this);
    QPixmap pix,pix2;
    // 画背景图
    pix.load(":/res/mapbg.jpeg");
    painter.drawPixmap(ui->site->geometry(),pix);
    //画坐标
    pix2.load(":/res/cursor.png");
    painter.drawPixmap(px-15,py-50,40,50,pix2);
    //画初始道路
    QPen pen1,pen2;
    pen1.setWidth(1);
    pen1.setColor(QColor(Qt::black));
    pen2.setWidth(3);
    pen2.setColor(QColor(Qt::red));
    painter.setPen(pen1);
    painter.drawLine(QPoint(ui->oneap->pos().x()+(ui->oneap->width()),ui->oneap->pos().y()+(ui->oneap->height())),
                     QPoint(ui->twoap->pos().x()+(ui->twoap->width()),ui->twoap->pos().y()+(ui->twoap->height())));
    painter.drawLine(QPoint(ui->oneap->pos().x()+(ui->oneap->width()),ui->oneap->pos().y()+(ui->oneap->height())),
                     QPoint(ui->threeap->pos().x()+(ui->threeap->width()),ui->threeap->pos().y()+(ui->threeap->height())));
    painter.drawLine(QPoint(ui->oneap->pos().x()+(ui->oneap->width()),ui->oneap->pos().y()+(ui->oneap->height())),
                     QPoint(ui->oneed->pos().x()+(ui->oneed->width()),ui->oneed->pos().y()+(ui->oneed->height())));
    painter.drawLine(QPoint(ui->oneap->pos().x()+(ui->oneap->width()),ui->oneap->pos().y()+(ui->oneap->height())),
                     QPoint(ui->twoed->pos().x()+(ui->twoed->width()),ui->twoed->pos().y()+(ui->twoed->height())));
    painter.drawLine(QPoint(ui->oneap->pos().x()+(ui->oneap->width()),ui->oneap->pos().y()+(ui->oneap->height())),
                     QPoint(ui->threeed->pos().x()+(ui->threeed->width()),ui->threeed->pos().y()+(ui->threeed->height())));
    painter.drawLine(QPoint(ui->oneap->pos().x()+(ui->oneap->width()),ui->oneap->pos().y()+(ui->oneap->height())),
                     QPoint(ui->lab->pos().x()+(ui->lab->width()),ui->lab->pos().y()+(ui->lab->height())));
    painter.drawLine(QPoint(ui->oneap->pos().x()+(ui->oneap->width()),ui->oneap->pos().y()+(ui->oneap->height())),
                     QPoint(ui->play->pos().x()+(ui->play->width()),ui->play->pos().y()+(ui->play->height())));
    painter.drawLine(QPoint(ui->oneap->pos().x()+(ui->oneap->width()),ui->oneap->pos().y()+(ui->oneap->height())),
                     QPoint(ui->spt->pos().x()+(ui->spt->width()),ui->spt->pos().y()+(ui->spt->height())));
    painter.drawLine(QPoint(ui->oneap->pos().x()+(ui->oneap->width()),ui->oneap->pos().y()+(ui->oneap->height())),
                     QPoint(ui->cafe->pos().x()+(ui->cafe->width()),ui->cafe->pos().y()+(ui->cafe->height())));


    painter.drawLine(QPoint(ui->twoap->pos().x()+(ui->twoap->width()),ui->twoap->pos().y()+(ui->twoap->height())),
                     QPoint(ui->oneed->pos().x()+(ui->oneed->width()),ui->oneed->pos().y()+(ui->oneed->height())));
    painter.drawLine(QPoint(ui->twoap->pos().x()+(ui->twoap->width()),ui->twoap->pos().y()+(ui->twoap->height())),
                     QPoint(ui->twoed->pos().x()+(ui->twoed->width()),ui->twoed->pos().y()+(ui->twoed->height())));
    painter.drawLine(QPoint(ui->twoap->pos().x()+(ui->twoap->width()),ui->twoap->pos().y()+(ui->twoap->height())),
                     QPoint(ui->threeed->pos().x()+(ui->threeed->width()),ui->threeed->pos().y()+(ui->threeed->height())));
    painter.drawLine(QPoint(ui->twoap->pos().x()+(ui->twoap->width()),ui->twoap->pos().y()+(ui->twoap->height())),
                     QPoint(ui->lab->pos().x()+(ui->lab->width()),ui->lab->pos().y()+(ui->lab->height())));
    painter.drawLine(QPoint(ui->twoap->pos().x()+(ui->twoap->width()),ui->twoap->pos().y()+(ui->twoap->height())),
                     QPoint(ui->cafe->pos().x()+(ui->cafe->width()),ui->cafe->pos().y()+(ui->cafe->height())));
    painter.drawLine(QPoint(ui->twoap->pos().x()+(ui->twoap->width()),ui->twoap->pos().y()+(ui->twoap->height())),
                     QPoint(ui->play->pos().x()+(ui->play->width()),ui->play->pos().y()+(ui->play->height())));
    painter.drawLine(QPoint(ui->twoap->pos().x()+(ui->twoap->width()),ui->twoap->pos().y()+(ui->twoap->height())),
                     QPoint(ui->spt->pos().x()+(ui->spt->width()),ui->spt->pos().y()+(ui->spt->height())));
    painter.drawLine(QPoint(ui->twoap->pos().x()+(ui->twoap->width()),ui->twoap->pos().y()+(ui->twoap->height())),
                     QPoint(ui->threeap->pos().x()+(ui->threeap->width()),ui->threeap->pos().y()+(ui->threeap->height())));


    painter.drawLine(QPoint(ui->threeap->pos().x()+(ui->threeap->width()),ui->threeap->pos().y()+(ui->threeap->height())),
                     QPoint(ui->twoed->pos().x()+(ui->twoed->width()),ui->twoed->pos().y()+(ui->twoed->height())));
    painter.drawLine(QPoint(ui->threeap->pos().x()+(ui->threeap->width()),ui->threeap->pos().y()+(ui->threeap->height())),
                     QPoint(ui->threeed->pos().x()+(ui->threeed->width()),ui->threeed->pos().y()+(ui->threeed->height())));
    painter.drawLine(QPoint(ui->threeap->pos().x()+(ui->threeap->width()),ui->threeap->pos().y()+(ui->threeap->height())),
                     QPoint(ui->lab->pos().x()+(ui->lab->width()),ui->lab->pos().y()+(ui->lab->height())));
    painter.drawLine(QPoint(ui->threeap->pos().x()+(ui->threeap->width()),ui->threeap->pos().y()+(ui->threeap->height())),
                     QPoint(ui->cafe->pos().x()+(ui->cafe->width()),ui->cafe->pos().y()+(ui->cafe->height())));
    painter.drawLine(QPoint(ui->threeap->pos().x()+(ui->threeap->width()),ui->threeap->pos().y()+(ui->threeap->height())),
                     QPoint(ui->play->pos().x()+(ui->play->width()),ui->play->pos().y()+(ui->play->height())));
    painter.drawLine(QPoint(ui->threeap->pos().x()+(ui->threeap->width()),ui->threeap->pos().y()+(ui->threeap->height())),
                     QPoint(ui->spt->pos().x()+(ui->spt->width()),ui->spt->pos().y()+(ui->spt->height())));
    painter.drawLine(QPoint(ui->threeap->pos().x()+(ui->threeap->width()),ui->threeap->pos().y()+(ui->threeap->height())),
                     QPoint(ui->oneed->pos().x()+(ui->oneed->width()),ui->oneed->pos().y()+(ui->oneed->height())));


    painter.drawLine(QPoint(ui->oneed->pos().x()+(ui->oneed->width()),ui->oneed->pos().y()+(ui->oneed->height())),
                     QPoint(ui->threeed->pos().x()+(ui->threeed->width()),ui->threeed->pos().y()+(ui->threeed->height())));
    painter.drawLine(QPoint(ui->oneed->pos().x()+(ui->oneed->width()),ui->oneed->pos().y()+(ui->oneed->height())),
                     QPoint(ui->lab->pos().x()+(ui->lab->width()),ui->lab->pos().y()+(ui->lab->height())));
    painter.drawLine(QPoint(ui->oneed->pos().x()+(ui->oneed->width()),ui->oneed->pos().y()+(ui->oneed->height())),
                     QPoint(ui->cafe->pos().x()+(ui->cafe->width()),ui->cafe->pos().y()+(ui->cafe->height())));
    painter.drawLine(QPoint(ui->oneed->pos().x()+(ui->oneed->width()),ui->oneed->pos().y()+(ui->oneed->height())),
                     QPoint(ui->play->pos().x()+(ui->play->width()),ui->play->pos().y()+(ui->play->height())));
    painter.drawLine(QPoint(ui->oneed->pos().x()+(ui->oneed->width()),ui->oneed->pos().y()+(ui->oneed->height())),
                     QPoint(ui->spt->pos().x()+(ui->spt->width()),ui->spt->pos().y()+(ui->spt->height())));
    painter.drawLine(QPoint(ui->oneed->pos().x()+(ui->oneed->width()),ui->oneed->pos().y()+(ui->oneed->height())),
                     QPoint(ui->twoed->pos().x()+(ui->twoed->width()),ui->twoed->pos().y()+(ui->twoed->height())));

    painter.drawLine(QPoint(ui->twoed->pos().x()+(ui->twoed->width()),ui->twoed->pos().y()+(ui->twoed->height())),
                     QPoint(ui->lab->pos().x()+(ui->lab->width()),ui->lab->pos().y()+(ui->lab->height())));
    painter.drawLine(QPoint(ui->twoed->pos().x()+(ui->twoed->width()),ui->twoed->pos().y()+(ui->twoed->height())),
                     QPoint(ui->cafe->pos().x()+(ui->cafe->width()),ui->cafe->pos().y()+(ui->cafe->height())));
    painter.drawLine(QPoint(ui->twoed->pos().x()+(ui->twoed->width()),ui->twoed->pos().y()+(ui->twoed->height())),
                     QPoint(ui->play->pos().x()+(ui->play->width()),ui->play->pos().y()+(ui->play->height())));
    painter.drawLine(QPoint(ui->twoed->pos().x()+(ui->twoed->width()),ui->twoed->pos().y()+(ui->twoed->height())),
                     QPoint(ui->spt->pos().x()+(ui->spt->width()),ui->spt->pos().y()+(ui->spt->height())));
    painter.drawLine(QPoint(ui->twoed->pos().x()+(ui->twoed->width()),ui->twoed->pos().y()+(ui->twoed->height())),
                     QPoint(ui->threeed->pos().x()+(ui->threeed->width()),ui->threeed->pos().y()+(ui->threeed->height())));

    painter.drawLine(QPoint(ui->threeed->pos().x()+(ui->threeed->width()),ui->threeed->pos().y()+(ui->threeed->height())),
                     QPoint(ui->play->pos().x()+(ui->play->width()),ui->play->pos().y()+(ui->play->height())));
    painter.drawLine(QPoint(ui->threeed->pos().x()+(ui->threeed->width()),ui->threeed->pos().y()+(ui->threeed->height())),
                     QPoint(ui->spt->pos().x()+(ui->spt->width()),ui->spt->pos().y()+(ui->spt->height())));
    painter.drawLine(QPoint(ui->threeed->pos().x()+(ui->threeed->width()),ui->threeed->pos().y()+(ui->threeed->height())),
                     QPoint(ui->lab->pos().x()+(ui->lab->width()),ui->lab->pos().y()+(ui->lab->height())));
    painter.drawLine(QPoint(ui->threeed->pos().x()+(ui->threeed->width()),ui->threeed->pos().y()+(ui->threeed->height())),
                     QPoint(ui->cafe->pos().x()+(ui->cafe->width()),ui->cafe->pos().y()+(ui->cafe->height())));

    painter.drawLine(QPoint(ui->lab->pos().x()+(ui->lab->width()),ui->lab->pos().y()+(ui->lab->height())),
                     QPoint(ui->play->pos().x()+(ui->play->width()),ui->play->pos().y()+(ui->play->height())));
    painter.drawLine(QPoint(ui->lab->pos().x()+(ui->lab->width()),ui->lab->pos().y()+(ui->lab->height())),
                     QPoint(ui->spt->pos().x()+(ui->spt->width()),ui->spt->pos().y()+(ui->spt->height())));
    painter.drawLine(QPoint(ui->lab->pos().x()+(ui->lab->width()),ui->lab->pos().y()+(ui->lab->height())),
                     QPoint(ui->cafe->pos().x()+(ui->cafe->width()),ui->cafe->pos().y()+(ui->cafe->height())));

    painter.drawLine(QPoint(ui->cafe->pos().x()+(ui->cafe->width()),ui->cafe->pos().y()+(ui->cafe->height())),
                     QPoint(ui->play->pos().x()+(ui->play->width()),ui->play->pos().y()+(ui->play->height())));
    painter.drawLine(QPoint(ui->cafe->pos().x()+(ui->cafe->width()),ui->cafe->pos().y()+(ui->cafe->height())),
                     QPoint(ui->spt->pos().x()+(ui->spt->width()),ui->spt->pos().y()+(ui->spt->height())));

    painter.drawLine(QPoint(ui->play->pos().x()+(ui->play->width()),ui->play->pos().y()+(ui->play->height())),
                     QPoint(ui->spt->pos().x()+(ui->spt->width()),ui->spt->pos().y()+(ui->spt->height())));

    if(cx[0]!=0 && cy[0]!=0){
        pen2.setWidth(3);
        pen2.setColor(QColor(Qt::red));
        painter.setPen(pen2);


        painter.drawLine(QPoint(cx[0],cy[0]),QPoint(cx[1],cy[1]));

    }

}

void innermap::mousePressEvent(QMouseEvent *ev)
{
    int x = ev->x();
    int y = ev->y();
    if(x>=70 && x<=(70+571) && y>=40 && y<=(40+561)){
        Qt::MouseButton mbtn = ev->button();
        if(mbtn==Qt::LeftButton){
            this->px=x;
            this->py=y;
            this->repaint();
            cout<<this->px<<" "<<this->py<<endl;
        }
    }




}


